package com.diana.controller;


import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.diana.common.PageUtils;
import com.diana.common.Utils;
import com.diana.entity.AlipayRefundRecord;
import com.diana.service.AlipayRefundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author anzhi
 * @since 2020-03-27
 */
@RestController
@RequestMapping("/admin/alipayRefundRecord")
public class AlipayRefundRecordController {

    @Autowired
    private AlipayRefundRecordService alipayRefundRecordService;

    @RequestMapping("/getList")
    public String getList(@RequestBody Map map){
        Integer index = Utils.toInteger(map.get("index"));
        Integer size = Utils.toInteger(map.get("size"));
        Page<AlipayRefundRecord> page = PageUtils.getPage(index, size);
        Wrapper wrapper = Condition.create().orderAsc(Collections.singleton("outTradeNo")).orderDesc(Collections.singleton("createTime"));
        Page<AlipayRefundRecord> result = alipayRefundRecordService.selectPage(page,wrapper);
        return Utils.message("0000","获取成功",result.getRecords(),result.getTotal());
    }
}

